from django.http import Http404
from django.shortcuts import render_to_response
from blog.models import Article


# Create your views here.


def detail(request, id):

    try:
        articleId = int(id)
    except ValueError:
        raise Http404()

    article = Article.objects.get(id=articleId)

    return render_to_response('blog/article/detail.html', {
        'article': article,
    })


def article_list(request, tag):

    articleList = Article.objects.filter(category__iexact=tag)

    return render_to_response('blog/article/list.html', {
        'articleList': articleList
    })
